{extend name="common/base" /}
{block name="extend-load"}
    {load href='__PUBLIC__/static/css/cikonss.css'}
    {load href='__PUBLIC__/static/filemanage/js/index.js'}
    {load href='__PUBLIC__/static/filemanage/css/index.css'}
{/block}
{block name="content"}
    <div id="headBar">
        <h6>欢迎你！{$data.username}&nbsp;&nbsp;<a href="{:url('login/logout')}">注销</a></h6>
    </div>
    <div id="navBar" class="nav">
		<a href="{:url('index?pos')}">
			<span class="icon icon-small icon-square" style="padding: 0;">
				<span class="icon-home"></span>
			</span>
		</a>
        <a href="javascript:;" data-url="{:url('file/create')}" onclick="showModal('newFile')">
			<span class="icon icon-small icon-square" style="padding: 0;">
				<span class="icon-file"></span>
			</span>
		</a>
		<a href="javascript:;" data-url="{:url('file/mkdir')}" onclick="showModal('newDir')">
			<span class="icon icon-small icon-square" style="padding: 0;">
				<span class="icon-folder"></span>
			</span>
		</a>
		
		<a href="javascript:;" onclick="showModal('upload')">
			<span class="icon icon-small icon-square" style="padding: 0;">
				<span class="icon-upload"></span>
			</span>
		</a>
		
		{if condition="$data.parentPath !== false"}
		<a href="{:url('index')}?pos={$data.parentPath}">
			<span class="icon icon-small icon-square" style="padding: 0;">
				<span class="icon-arrowLeft"></span>
			</span>
		</a>
		{/if}
    </div>
    <div>
        <h6>当前路径为：/{$data['currentPath']}</h6>
    </div>


    <table id="content-table" class="table table-striped table-bordered table-hover table-condensed" data-view-file="{:url('file/view')}" data-delete-file="{:url('file/delete')}">
        <thead>
            <tr>
                <th>#</th>
                <th>名称</th>
                <th>类型</th>
                <th>大小</th>    
                <th>可读</th>
                <th>可写</th>
                <th>可执行</th>
                <th>修改时间</th>
                <th>访问时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {volist name="info" id="info"}
                <tr data-path="data.currentPath">
                    <td>{$key}</td>
                    <td>
                    	{if condition="$info.type==1"}
                    		<a href="{:url('index')}?pos={$data.currentPath.$info.name}/">{$info.name}</a>
                    	{else /}
                    		{$info.name}
                    	{/if}
                    </td>
                    <td><span class="glyphicon glyphicon-{$info.type?'folder-open':'file'}" aria-hidden="true"></span></td>
                    <td>{$info.size}</td>
                    <td><span class="glyphicon glyphicon-{:$info.perms&4?'ok':'remove'}" aria-hidden="true"></span></td>
                    <td><span class="glyphicon glyphicon-{:$info.perms&2?'ok':'remove'}" aria-hidden="true"></span></td>
                    <td><span class="glyphicon glyphicon-{:$info.perms&1?'ok':'remove'}" aria-hidden="true"></span></td>
                    <td>{$info.mtime}</td>
                    <td>{$info.atime}</td>
                    <td class="operate" data-path="{$info.path}" data-type="{$info.type}">
                        <span class="glyphicon glyphicon-eye-open" aria-hidden="true" onclick="view()"></span>
                    	{if condition="$info.type==0"}
                    		<!-- <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> -->
                    		<a href="{:url('file/download')}?path={$info.path}"><span class="glyphicon glyphicon-download" aria-hidden="true"></span></a>
						{/if}
                        <span class="glyphicon glyphicon-remove" aria-hidden="true" onclick="del()"></span>
                    </td>
                </tr>
            {/volist}
        </tbody>
    </table>

    <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">Modal title</h4>
                </div>
                <div class="modal-body">
                    <p>One fine body&hellip;</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary">Save changes</button>
                </div>
            </div>
        </div>
    </div>

    <div id="create-modal" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">11</h4>
                </div>
                <div class="modal-body">
                    <form action="{:url('file/create')}" method="post">
                        <div class="form-group">
                            <label for="newFile" id="laber-create">11</label>
                            <input type="text" id="newFile" name="filename">
                            <input type="hidden" name="pos" value="{$data.currentPath}">
                        </div>
                         <button type="submit" class="btn btn-default">提交</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <div id="upload-modal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">上传文件</h4>
                </div>
                <div class="modal-body">
                    <form class="file-upload" action="{:url('file/upload')}" method="POST" enctype="multipart/form-data" >
                        <div class="form-group">
                            <label for="fileUpload">请选择上传的文件</label>
                            <input type="file" id="fileUpload" name="file">
                        </div>
                        <input type="hidden" name="pos" value="{$data.currentPath}">
                        <button type="submit" class="btn btn-default">提交</button>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <div id="viewer-modal" class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                    <div class="modal-body">
                        <div id="viewer-text">
                            <!-- <form id="file-viewer" action="{:url('file/edit')}" method="POST"> -->
                                <!-- <div class="form-group"> -->
                                    <!-- <label for="fileViewer">filename</label> -->
                                    <textarea class="form-control" rows="20" id="fileViewer" name="text"></textarea>
                                <!-- </div> -->
                                <!-- <input type="hidden" name="pos" value="{$data.currentPath}"> -->
                                <!-- <button type="submit" class="btn btn-default">提交</button> -->
                            <!-- </form> -->
                        </div>
                    </div>
                    <div id="viewer-image">
                        <img src="" alt="">
                    </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
{/block}